package com.xej.seat.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xej.seat.mapper.HallMapper;
import com.xej.seat.service.HallService;
import com.xej.seat.service.SeatService;
import com.xej.seat.vo.Hall;
import com.xej.seat.vo.Seat;

@Service
@Transactional(rollbackFor = Exception.class)
public class HallServiceImpl implements HallService{
	
	@Autowired
	private HallMapper hallMapper;
	
	@Autowired
	private SeatService seatService;
	
	@Override
	public void createHallSeat(Hall hall) {
		this.hallMapper.addHall(hall);
		for(int i=1; i<=hall.getTolCol(); i++) {
			for(int j=1; j<=hall.getTolCol(); j++) {
				Seat seat = new Seat(hall.getHallId(), i, j);
				this.seatService.addSeat(seat);
			}
		}
	}	
	
	@Override
	public Hall queryHallById(String hallId) {
		return this.hallMapper.queryHallById(hallId);
	}

	@Override
	public List<Hall> queryHallListByParams(Map<String, Object> params) {
		// TODO Auto-generated method stub
		return null;
	}

}
